##
## Copyright (c) 2020-2021 IOTech Ltd
##
## Licensed under the Apache License, Version 2.0 (the "License");
## you may not use this file except in compliance with the License.
## You may obtain a copy of the License at
##
##      http://www.apache.org/licenses/LICENSE-2.0
##
## Unless required by applicable law or agreed to in writing, software
## distributed under the License is distributed on an "AS IS" BASIS,
## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
## See the License for the specific language governing permissions and
## limitations under the License.
##
#
#ARG BASE=golang:1.16-alpine3.12
#FROM ${BASE} AS builder
#ARG ALPINE_PKG_BASE="make git openssh-client gcc libc-dev zeromq-dev libsodium-dev"
#ARG ALPINE_PKG_EXTRA=""
#
## Replicate the APK repository override.
## If it is no longer necessary to avoid the CDN mirros we should consider dropping this as it is brittle.
#RUN sed -e 's/dl-cdn[.]alpinelinux.org/nl.alpinelinux.org/g' -i~ /etc/apk/repositories
## Install our build time packages.
#RUN apk add --update --no-cache ${ALPINE_PKG_BASE} ${ALPINE_PKG_EXTRA}
#
#WORKDIR /device-iec61850
#
#COPY . .
#
#RUN go mod tidy
#RUN go mod download
#
## To run tests in the build container:
##   docker build --build-arg 'MAKE=build test' .
## This is handy of you do your Docker business on a Mac
#ARG MAKE='make build'
#RUN $MAKE
#
#FROM alpine:3.12
#
## dumb-init needed for injected secure bootstrapping entrypoint script when run in secure mode.
#RUN apk add --update --no-cache zeromq dumb-init
#
#COPY --from=builder /device-iec61850/cmd /
#
#EXPOSE 59988
#
#ENTRYPOINT ["/device-iec61850"]
#CMD ["--cp=consul://edgex-core-consul:8500", "--confdir=/res", "--registry"]

#FROM golang:1.18-alpine AS builder
#
#RUN apk add --update --no-cache gcc libc-dev zeromq-dev
#WORKDIR /build
##VOLUME ["/build/vendor/","/go/pkg/mod/","/root/.cache/go-build"]
#COPY . .
#ENV GO111MODULE=on
#ENV GOPROXY=https://goproxy.cn,direct
#RUN go mod tidy
#RUN go mod download
#RUN go mod vendor
#RUN go build  -o cmd/app-webapi main.go

FROM alpine
ENV EDGEX_SECURITY_SECRET_STORE=false
RUN apk add --update --no-cache zeromq
RUN apk add libc6-compat
RUN apk add gcompat
RUN ln -s /lib/libc.musl-x86_64.so.1 /lib64/ld-linux-x86-64.so.2
RUN ln -s /lib/libc.so.6 /usr/lib/libresolv.so.2
WORKDIR /
RUN pwd
COPY ./cmd /
RUN ls
COPY ./res/configuration.toml /res/configuration.toml
RUN chmod +x carbon-monitor-app
EXPOSE 59782 58782
ENTRYPOINT ["/carbon-monitor-app"]
CMD ["--cp=consul://edgex-core-consul:8500", "--registry", "--confdir=/res"]
#CMD ["sleep","1000000"]

#FROM alpine
#ENV EDGEX_SECURITY_SECRET_STORE=false
#RUN apk add --update --no-cache zeromq
#WORKDIR /
#COPY ./cmd .
#COPY ./res/configuration.toml ./res/configuration.toml
#RUN chmod +x app-webapi
#EXPOSE 59781 58781
#ENTRYPOINT ["./app-webapi"]
#CMD ["--cp=consul://edgex-core-consul:8500", "--registry", "--confdir=/res"]